Tip Corner - Wisdom for Beginners

© 2004, Norman

author contact:

krabtree@blueyonder.com

Home

Tip Corner

API Corner

Qcard DLL #5

Sprite Byte

Projectile Motion

Sub Handlers

Agent Lesson

LB Server

A Web Presence

Website Review

An Interview

DoubleClick

Disk Cleaner

Newsletter help

Index


Introduction

Often the Tip Corner points out little known LB tricks and concepts that solve often asked questions. This month I wanted to address the idea of Doing the right thing first, before doing things right. I was prepared to write something snappy, and ramble on for a while, but instead Norman seems to have accidentally come to your rescue. Earlier this fall he posted the following bit of beginner insight on the Liberty Basic conforums web site. It generated a lot of great discussion, but even more important, it shows that a great utility can be made with minimal fuss. As the quote this month reminds us - do the right thing first. I could not have said it better than Norman did, so I defer to him and his wisdom with thanks for letting me republish:

In Norman's words

If you are just starting out on the exciting trail of programming, it can sometimes be a bit frustrating. This frustration often comes about because we try to go too fast. I believe that it is better to create some straight forward simple programs, just using the limited knowledge that we might have, rather than trying to learn more complicated commands and procedures before we have consolidated what we have only just learned.

You may think that it is not possible to write any sort of useful program with just a few basic commands. That is NOT true. With just a very few commands you can start to create some meaningful programs. They may not be great masterpieces or as visually appealing as the programs that more experienced programmers write, but they are the stepping stones to becoming an experienced programmer.

Let me give you a simple example program that you can create with a very limited set of commands. It is a program to do various conversions.

The Code


[enterOption]
       CLS
       PRINT "IMPORTANT: You must enter a number from 1 to 3"
       PRINT""
       PRINT "1. Convert Kilograms to pounds"
       PRINT "2. Convert Kilometres to miles"
       PRINT "3. Convert Celsius to Fahrenheit"
       PRINT ""
       INPUT "Which option? Enter number (1 to 3)";option
       IF option <1 or option>3 THEN [enterOption]
       option=int(option)
       IF option=1 THEN GOSUB [kilograms2Pounds]
       IF option=2 THEN GOSUB [kilometres2Miles]
       IF option=3 THEN GOSUB [celsius2Fahrenheit]

       CONFIRM "Do you want to do some more conversions?";again$
       IF again$="yes" THEN [enterOption]
END

[kilograms2Pounds]
       CLS
       INPUT "Please enter the number of kilograms ";kilograms
       pounds=kilograms*2.2046
       PRINT kilograms;" kilograms is ";pounds;" pounds"
RETURN

[kilometres2Miles]
       CLS
       INPUT "Please enter the number of kilometres ";kilometres
       miles=kilometres*0.6214
       PRINT kilometres;" kilometres is ";miles;" miles"
RETURN

[celsius2Fahrenheit]
       CLS
       INPUT "Please enter the number of degrees Celsius ";celsius
       fahrenheit=celsius*9/5+32
       PRINT celsius;" degrees C is ";fahrenheit;" degrees F"
RETURN

Pulling it together

OK, it's not a pretty program, but it actually does something useful. One useful aspect of the program is that you can add more conversions to it, thereby adding to your programming experience, and/or you can start to enhance it's visual appeal when you start to learn new commands. You might consider changing the "kilograms to pounds" routine so that the answer is shown in pounds and ounces instead of decimal pounds.

If you want to add new conversions, you will need to know the multipliers that are needed. You can find these on various websites. [Here] is one that I have used.

What I am trying to say here, is that you should not expect to create fancy programs with fancy commands, until you have mastered the basics. Make use of what you already know to write some programs, then each time you learn something new, go back to your earlier program and see if they can be improved. By this process, you should gradually increase you experience of programming. There are no shortcuts to becoming proficient. It is by continually, using what you know, and adding in new commands as you learn about them, that will make you a more proficient programmer.


Home

Tip Corner

API Corner

Qcard DLL #5

Sprite Byte

Projectile Motion

Sub Handlers

Agent Lesson

LB Server

A Web Presence

Website Review

An Interview

DoubleClick

Disk Cleaner

Newsletter help

Index